package simportal.persistent;

import java.util.ArrayList;
import java.util.List;

import com.cfuture08.eweb4j.orm.config.annotation.Column;
import com.cfuture08.eweb4j.orm.config.annotation.Id;
import com.cfuture08.eweb4j.orm.config.annotation.ManyMany;
import com.cfuture08.eweb4j.orm.config.annotation.Table;
import com.cfuture08.util.JsonConverter;

/**
 * 角色-持久化对象
 * 
 * @author weiwei[l.weiwei@163.com]
 * 
 */
@Table("t_Role")
public class Role {
	@Id
	@Column("")
	private Integer id;//自增长ID
	@Column("")
	private String name;//角色名称
	@Column("")
	private String description;//角色描述
	//角色用户多对多关系
	@ManyMany(target = User.class, relTable = "t_User_Role", from = "roleId", to = "userId")
	private List<User> users = new ArrayList<User>();//用户
	//角色权限多对多关系
	@ManyMany(target=Permission.class,relTable="t_Role_Permission",from="roleId",to="permissionId")
	private List<Permission> permissions = new ArrayList<Permission>();//权限
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public List<User> getUsers() {
		return users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}

	public List<Permission> getPermissions() {
		return permissions;
	}

	public void setPermissions(List<Permission> permissions) {
		this.permissions = permissions;
	}
	
	public String toString(){
		return JsonConverter.convert(this);
	}
}
